package cn.mysdp.biz.facade;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import cn.mysdp.biz.dto.request.*;
import cn.mysdp.biz.dto.response.*;
import cn.mysdp.biz.domain.*;
import cn.mysdp.biz.facade.*;
import cn.mysdp.biz.facade.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: SdpWorkspaceFacadeImpl
 * @Description:
 * @Author: SDP
 * @Date: 2021-10-30
 * @Version: 1.0
 * Table: sdp_workspace
 * Comment:
 * workspace
 */
@Service
public class SdpWorkspaceFacadeImpl extends SdpWorkspaceFacadeCustomImpl implements SdpWorkspaceFacade {

    static {
        beanClassNameMap.put("sdp_workspace", "sdpWorkspaceFacadeImpl");
        listMethodNameMap.put("sdp_workspace", "listSdpWorkspace");
        listMethodParameterClassNameMap.put("sdp_workspace", "SdpWorkspaceQueryRequest");
        updateMethodNameMap.put("sdp_workspace", "updateSdpWorkspace");
        updateMethodParameterClassNameMap.put("sdp_workspace", "SdpWorkspaceUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addSdpWorkspace(SdpWorkspaceAddRequest request) throws Exception {
        super.fixRequest("sdp_workspace", "add", request);
        return super.addSdpWorkspace(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateSdpWorkspace(SdpWorkspaceUpdateRequest request) throws Exception {
        SdpWorkspace record = null;
        record = sdpWorkspaceMapper.selectByPrimaryKey(request.getId());
        super.fixRequest("sdp_workspace", "update", request, record);
        return super.updateSdpWorkspace(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteSdpWorkspace(SdpWorkspaceDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<SdpWorkspace> list = null;
            SdpWorkspaceExample example = new SdpWorkspaceExample();
            example.createCriteria().andIdIn(request.getIdList());
            list = sdpWorkspaceMapper.selectByExample(example);
            fixRequest("sdp_workspace", "delete", request, list);
        } else {
            fixRequest("sdp_workspace", "delete", request);
        }
        return super.deleteSdpWorkspace(request);
    }

    @Override
    public SdpWorkspaceQueryResponse querySdpWorkspace(SdpWorkspaceQueryRequest request) throws Exception {
        super.checkNonNull(request.getId(), "id");
        SdpWorkspaceQueryResponse result = super.querySdpWorkspace(request);
        checkResult("sdp_workspace", "query", request, result);
        return result;
    }

    @Override
    public List<SdpWorkspaceQueryResponse> listSdpWorkspace(SdpWorkspaceQueryRequest request) throws Exception {
        List<SdpWorkspaceQueryResponse> list = super.listSdpWorkspace(request);
        checkResult("sdp_workspace", "list", request, list);
        return list;
    }

    @Override
    public Integer countSdpWorkspace(SdpWorkspaceQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_workspace", "count", request);
        return super.countSdpWorkspace(request);
    }

    @Override
    public BaseStatResponse statSdpWorkspace(SdpWorkspaceQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_workspace", "stat", request);
        return super.statSdpWorkspace(request);
    }

    @Override
    public List<SdpWorkspaceForGetColumnListResponse> getColumnList(SdpWorkspaceForGetColumnListRequest request) throws Exception {
        super.fixRequest("sdp_workspace", "get_column_list", request);
        List<SdpWorkspaceForGetColumnListResponse> list = super.getColumnList(request);
        checkResult("sdp_workspace", "get_column_list", request, list);
        return list;
    }

    @Override
    public Integer countForGetColumnList(SdpWorkspaceForGetColumnListRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_workspace", "count_for_get_column_list", request);
        return super.countForGetColumnList(request);
    }

    @Override
    public BaseStatResponse statForGetColumnList(SdpWorkspaceForGetColumnListRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_workspace", "stat_for_get_column_list", request);
        return super.statForGetColumnList(request);
    }

    @Override
    public List<SdpWorkspaceForGetTableListResponse> getTableList(SdpWorkspaceForGetTableListRequest request) throws Exception {
        super.fixRequest("sdp_workspace", "get_table_list", request);
        List<SdpWorkspaceForGetTableListResponse> list = super.getTableList(request);
        checkResult("sdp_workspace", "get_table_list", request, list);
        return list;
    }

    @Override
    public Integer countForGetTableList(SdpWorkspaceForGetTableListRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_workspace", "count_for_get_table_list", request);
        return super.countForGetTableList(request);
    }

    @Override
    public BaseStatResponse statForGetTableList(SdpWorkspaceForGetTableListRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_workspace", "stat_for_get_table_list", request);
        return super.statForGetTableList(request);
    }

    @Override
    public List<SdpWorkspaceForGetDbConfigResponse> getDbConfig(SdpWorkspaceForGetDbConfigRequest request) throws Exception {
        super.fixRequest("sdp_workspace", "get_db_config", request);
        List<SdpWorkspaceForGetDbConfigResponse> list = super.getDbConfig(request);
        checkResult("sdp_workspace", "get_db_config", request, list);
        return list;
    }

    @Override
    public Integer countForGetDbConfig(SdpWorkspaceForGetDbConfigRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_workspace", "count_for_get_db_config", request);
        return super.countForGetDbConfig(request);
    }

    @Override
    public BaseStatResponse statForGetDbConfig(SdpWorkspaceForGetDbConfigRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_workspace", "stat_for_get_db_config", request);
        return super.statForGetDbConfig(request);
    }

    @Override
    public Integer clone(BaseNameIdRequest request) throws Exception {
        super.fixRequest("sdp_workspace", "clone", request);
        Integer result = super.clone(request);
        checkResult("sdp_workspace", "clone", request, result);
        return result;
    }

    @Override
    public Integer cloneWorkspace(BaseNameIdRequest request) throws Exception {
        super.fixRequest("sdp_workspace", "clone_workspace", request);
        Integer result = super.cloneWorkspace(request);
        checkResult("sdp_workspace", "clone_workspace", request, result);
        return result;
    }

    @Override
    public String fixJsonObject(BaseNameRequest request) throws Exception {
        super.fixRequest("sdp_workspace", "fix_json_object", request);
        String result = super.fixJsonObject(request);
        checkResult("sdp_workspace", "fix_json_object", request, result);
        return result;
    }

    @Override
    public String testConnect(SdpWorkspaceUpdateRequest request) throws Exception {
        super.fixRequest("sdp_workspace", "test_connect", request);
        String result = super.testConnect(request);
        checkResult("sdp_workspace", "test_connect", request, result);
        return result;
    }

}
